import cn.hutool.core.date.StopWatch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Slf4j
public class CryptoTest {

    private static final PasswordEncoder BCRYPT = new BCryptPasswordEncoder();
    private static final PasswordEncoder BCRYPT_12 = new BCryptPasswordEncoder(12);
    private static final PasswordEncoder ARGON_2 = Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8();

    public static void main(String[] args) {
        var data = "hello123123";
        var stopWatch = new StopWatch("CryptoTest");

        stopWatch.start("BCRYPT");
        var encode = BCRYPT.encode(data);
        stopWatch.stop();
        log.info(encode);

        stopWatch.start("BCRYPT_12");
        encode = BCRYPT_12.encode(data);
        stopWatch.stop();
        log.info(encode);

        stopWatch.start("ARGON_2");
        encode = ARGON_2.encode(data);
        stopWatch.stop();
        log.info(encode);

        // 输出结果
        log.info(stopWatch.prettyPrint());
    }
}
